#!/bin/bash
set -e

export PGPASSFILE=/docker-entrypoint-initdb.d/.pgpass
psql -v ON_ERROR_STOP=1 <<-EOSQL
	CREATE USER grafana WITH PASSWORD '$POSTGRES_PASSWORD';
	CREATE DATABASE grafana OWNER grafana;
	GRANT ALL PRIVILEGES ON DATABASE grafana TO grafana;
	CREATE USER dev WITH PASSWORD '$POSTGRES_PASSWORD';
	CREATE DATABASE dev OWNER dev;
	GRANT ALL PRIVILEGES ON DATABASE dev TO dev;
EOSQL
